# 钟奕升 2311020118
# 课堂练习 20240511
# 字符串函数
print(chr(ord('A')+32))
print(chr(ord('a')-32))
zf001 = '  666 D ad DSASDSDsdadsaadDD NNN 哈哈哈哈 。、，！@#￥%……&*（）'
for a in zf001:
    if (ord(a)>122) or (ord(a)<97):
         print(a,end="")
    else:
        print(chr(ord(a)-32),end="")

print()
print('字符串的子串')
print(zf001[4:20:1])
print(zf001[:20:])
print(zf001[0:20:3])
print("字符串大小写转换函数------------------------------------------------------------------------------------")
print(zf001.upper())
print(zf001.lower())
print(zf001)
print('字符串查找=========================')
print(zf001.find("哈哈"))
print(zf001.find("#$%^&"))
print(zf001.rfind("NNN"))
print(zf001.rfind("345"))
print(zf001.index('哈哈'))
try:
    print(zf001.index('&&'))
except Exception as eqq:
    print(eqq)
print('字符串开始和结束===================================================================')
print(zf001.startswith("  "))
print(zf001.startswith("W"))
print(zf001.endswith("  "))
print(zf001.endswith("A "))
print('去掉字符串俩边空格--------------')
print(zf001.lstrip())
print(zf001.rstrip())
zf002 = zf001.strip()
print(zf002)
print(zf001)
print('字符串分离函数：==========')
print(zf001.split(' '))

